package edu.cuit.avatar.generic;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/14 10:34
 */
public class GenericMethodDemo {
    public static<E> void printArray(E[] list){
        for (int i = 0; i < list.length; i++)
            System.out.print(list[i] + " ");
        System.out.println();
    }

    public static void main(String[] args ) {
        Integer[] integers = {1, 2, 3, 4, 5};
        String[] strings = {"London", "Paris", "New York", "Austin"};
        GenericMethodDemo.printArray(integers);//或者print(integers);
        GenericMethodDemo.printArray(strings);//或者print(strings);实际类型没有明确指定。编译器自动发现实际类型
    }
}
